A database management system is usually equipped with a special lock mechanism that synchronizes access to data on the database. The purpose of the lock mechanism is to prevent two transactions from changing the same data on the database simultaneously.
Locks may be defined generically as “lock objects”. A lock entry is a specific instance of a lock object and locks a certain database object, such as a correction or a table entry or a file or a whole table.
Locks are usually set and deleted automatically when user programs access a data object and release it again.
When interactive transactions are programmed, locks may be set and released by calling specific function modules.
The tables in which data records should be locked with a lock entry are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also be added using foreign key relationships, for example.
The lock argument of a table in the lock object may consist of the key fields of the table. The lock argument fields of a lock object may be used as input parameters in the function modules for setting and removing locks generated from the lock object definition. When these function modules are called, the table entries to be locked or unlocked are specified by defining certain values in these fields. These values can also be generic or wildcards. The lock argument fields, therefore, define which subset of the table entries should be locked.
A simple case of a lock object comprises of exactly one table and the lock argument of the table is the primary key of this table. Several tables can also be included in a lock object. A lock entry, therefore, can lock an entire logical object, and not only a record of a table. Such a logical object can be, for example, a document comprising an entry in a header table and N entries in a position table.
Further, a lock mode may be assigned for each table in the lock object. This mode may define how other users can access a locked record of the table. The lock mode controls, for example, whether several users can access data records at the same time. The lock mode can be assigned separately for each table in the lock object. When the lock is set, the corresponding lock entry is stored in the lock table of the system for each table.
Access by more than one user can be synchronized in the following ways:
Exclusive Lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
Shared Lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
Exclusive But Not Cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
It is possible to synchronize access by several programs to the same data with a logical lock mechanism having two main functions: A program can tell other programs which data records it is just reading or changing. A program can prevent itself from reading data that is just being changed by another program.
Data records of a table to be locked may also be defined by a logical condition. When a lock is set, for example, this logical condition is entered in a lock table. This entry is retained until it is removed by the program or the program comes to an end. All the locks set by a program are thus removed at the end of the program.
When accessing data records, the records being edited by other programs may be identified by the entry in the lock table. Such an entry for the lock may define a number of fully specified key fields. That is, either a value is passed for the key field or this field is locked generically by means of a wildcard.
In a multi-user system environment, as is frequently the case in enterprise business software and computer system enivornments, data that is being processed by one user has to be locked, so that a second user can not change it at the same time. This is essential to avoid data inconsistencies.
Usually, the data is being locked via a key of the processed data (e.g., a document number, cost center ID). However, business transactions that process a lot of data at the same time (e.g., the costing of a car with several thousand components or the evaluation of a value flow net between many cost centers, activities and cost objects) can not lock every single piece of data via its key, since the number of locks that can be set is restricted because of limited hardware resources. For instance, a reasonable number of locks per transaction may be around 50 for larger multi-user systems. Anything more could harm the performance of the system. This is especially true, if several hundreds or thousands of users work at the same time setting locks in the system.
Thus, mass transactions such as those described above can not lock every single piece of data (e.g., every product number or cost center ID). Instead, wildcards are typically used in a lock entry so that it affects several single keys and many pieces of data can be locked via one entry (so-called “generic locking”).
Wildcards, however, have to be used with care. Otherwise, too much data may be locked and other users can't continue with their tasks since they can't access needed data. For instance, during the calculation of a product with 100 sub-products, one can not lock all products by only having a wildcard in the lock entry for the product. Otherwise, other users could not run a costing of an independent product.
Another example of a lock mechanism in a multi-user system environment is presented in the following document: READ, Paul: “SAP-Database Administration with Microsoft SQL Server 2000,” Galieo Press GmbH, Germany, pages 19–42 (2002). The document discloses a locking mechanism in a SAP/R3 system. As presented therein, a lock server (enqueue-server) administers logical locks in a lock table stored in the main memory of an application server. In that lock table, logical locks are set on a transaction level, whereas in the database management system (DBMS), the database locks are activated on a record level. During runtime, an application sends a lock requests to the lock server, which queries the lock table for an entry in conflict with the lock request. If such an entry is found, the lock server rejects the lock request and sends a message to the user. If no conflicting entry is found, the lock server confirms the lock request and the application performs/stores the transaction, thereby locking the respective data objects via the DBMS.
In a highly dynamic and analytical working environment dealing with many data objects, none of the solutions mentioned above might be the only optimal one. It depends on how many users work with the data and how often objects are changed.
Furthermore, when working with data in a change mode, every object change has to request a lock first. This costs time and might be annoying for users wanting to go quickly through some data changes.
Thus, there is a need for improved methods, software applications and/or data processing systems that can provide a more efficient solution to one or more of the problems described above. Furthermore, it is desirable to provide a mechanism for locking data more efficiently.
The above description is based on the knowledge of the present inventors and not necessarily that known in the art.